{extend name='extra@admin/content'}
{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <a href='javascript:history.back(-1)' class='layui-btn layui-btn-small' style="text-decoration:none" onclick="daochu();">返回</a>
    <!--<button data-modal='{:url("$classuri/change_stock")}?id={$goods.id}' data-title="返回" class='layui-btn layui-btn-small'>-->
        <!--<i class='fa fa-plus'></i> 返回-->
    <!--</button>-->

</div>
{/block}
{block name="content"}
<!-- 表单搜索 开始 -->

<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="true" method="post">
    {if empty($list)}
    <p class="help-block text-center well">没 有 记 录 哦！</p>
    {else}
    <input type="hidden" value="resort" name="action"/>
    <table class="layui-table" lay-skin="line" lay-size="sm">
        <thead>
            <tr>
               <!--  <th class='list-table-check-td'>
                    <input data-none-auto="" data-check-target='.list-check-box' type='checkbox'/>
                </th> -->
                <th class='text-left nowrap'>商品</th>
                <th class='text-left nowrap'>属性</th>
                <th class='text-left nowrap'>库存</th>
                <th class='text-left nowrap'>操作</th>
                <!-- <th class='text-left nowrap'>排序</th> -->
                <!-- <th class='text-left nowrap'>操作</th> -->
            </tr>
        </thead>
        <tbody>
            <!-- {notempty name="list"} -->
            {foreach $list as $key=>$vo}
                <tr>
                    <!-- <td class='list-table-check-td'>
                        <input class="list-check-box" value='{$vo.id}' type='checkbox'/>
                    </td> -->
                    <td class='text-left nowrap'>
                        {$goods.name}
                    </td>
                    <td class='text-left nowrap'>
                        {if condition="!empty($vo.title)"}{$vo.title}{else /}无属性{/if}
                    </td>
                    <td class='text-left nowrap'>
                        {$vo.stock}
                    </td>
                    <td class='text-left nowrap'>
                        {if auth("$classuri/change_stock")}
                        <span class="text-explode">|</span>
                        <a data-modal='{:url("$classuri/change_stock")}?goods_id={$vo.goods_id}&goods_spec_id={$vo.id}' href="javascript:void(0)">变更库存</a>
                        {/if}
                        {if auth("$classuri/stock_log")}
                        <span class="text-explode">|</span>
                        <a data-open='{:url("$classuri/stock_log")}?goods_id={$vo.goods_id}&goods_spec_id={$vo.id}' href="javascript:void(0)">库存日志</a>
                        {/if}
                    </td>
                </tr>
            {/foreach}
    <!--         {else /}
                <tr>
                    <td class='text-left nowrap'>
                        {$goods.name}
                    </td>
                    <td class='text-left nowrap'>
                        无属性
                    </td>
                    <td class='text-left nowrap'>
                        {$vo.stock}
                    </td>
                    <td class='text-left nowrap'>
                        {$vo.addtime|date="Y-m-d",###}
                    </td>
                </tr>
            {/notempty} -->
        </tbody>
    </table>
    {if isset($page)}<p>{$page}</p>{/if}
    {/if}
    <script>
        window.laydate.render({range: true, elem: '#range-date', format: 'yyyy/MM/dd'});
        function daochu(){
            var material_id = $('#material_id option:selected').val();       //搜索条件
            if(material_id > 0){
                window.location='{:url("$classuri/stock_log")}?export=1&material_id='+material_id;
            }else{
                window.location='{:url("$classuri/stock_log")}?export=1';
            }
        }

        function change_stock(obj){
            var goods_id = $(obj).attr('goods_id');
            window.location='{:url("$classuri/change_stock")}?goods_id='+goods_id;
        }
    </script>
</form>
{/block}